// pages/detailed/detailed.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    // 星钻收入/结算明细数组
    arrayIncome: [],
    arrayPay: [],
    sign: ''
  },
  // 获取收入明细
  income() {
    var that = this
    wx.request({
      url: app.globalData.baseUrl2 + '/merchant/merchantDetailByMark',
      data: {
        xcxOpenId: app.globalData.xcxOpenId2,
        pageNum: 1,
        pageSize: 10,
        mark: 1, //1收入 2支出
        moneyType: 3 //1微信支付 2ZC支付 3星钻支付
      },
      success(res) {
        var data = res.data.data.rows
        that.setData({
          arrayIncome: data,
          sign: '+'
        })
      }
    })
  },
  // 获取结算明细
  pay() {
    var that = this
    wx.request({
      url: app.globalData.baseUrl2 + '/merchant/merchantDetailByMark',
      data: {
        xcxOpenId: app.globalData.xcxOpenId2,
        pageNum: 1,
        pageSize: 10,
        mark: 2, //1收入 2支出
        moneyType: 3 //1微信支付 2ZC支付 3星钻支付
      },
      success(res) {
        var data = res.data.data.rows
        that.setData({
          arrayPay: data,
          sign: '-'
        })
      }
    })
  },
  onChange(event) {
    switch (event.detail.title) {
      case '收入':
        this.income()
        break;
      case '结算':
        this.pay()
        break;
    }
  }
})